home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-09-02 | 2.8 KB | 83 lines | [TEXT/CCL2] |
- ;;; docs-menu.lisp
- ;;;
- ;;; Paul McCartney, Spring 1992
- ;;;
- ;;; Copyright © 1992 Paul McCartney. All Rights Reserved.
- ;;;
- ;;; Washington University Medical Informatics Training Program
- ;;;
- ;;; DESCRIPTION:
- ;;;
- ;;; docs-menu (short for "Documents Menu") is a menu that lists all
- ;;; files matching a certain pattern. The files can be quickly opened
- ;;; by choosing it from the docs menu. The idea is to minimize the use
- ;;; of the open file dialog, saving time.
- ;;;
- ;;; USE:
- ;;;
- ;;; initialize-menu-tools - initialization
- ;;; *menu-item-separator* - globally bound menu item of a menu separator
- ;;; make-docs-menu - create the docs menu given a list of directories
- ;;; and file patterns
- ;;;
- ;;; HISTORY:
- ;;;
- ;;; 7/12/90 Created. - PM
- ;;; 4/10/92 Updated to MCL 2.0. - PM
- ;;;
-
- (in-package :ccl)
-
- (eval-when (:compile-toplevel :load-toplevel :execute)
- (export '(initialize-menu-tools *menu-item-separator* make-docs-menu)))
-
-
- ;;; This is a global menu item that is a separator between menu
- ;;; items in a menu.
- ;;;
- (defvar *menu-item-separator*)
-
-
- (defun initialize-menu-tools ()
- (setf *menu-item-separator*
- (make-instance 'menu-item :menu-item-title "-")))
-
-
- ;;; This creates a menu containing a list of directory menus and possibly
- ;;; separators. Each directory menu contains the name of a file matching
- ;;; a pattern in the directory. When the name of a file is selected from
- ;;; the menu, the file is opened for editing.
- ;;;
- ;;; dirs-and-patterns is a list. Each element of the list is either a
- ;;; (list <directory> <pattern>) or a non-list. Non-list elements are
- ;;; assumed to denote a menu item separator.
- ;;;
- (defun make-docs-menu (name dirs-and-patterns)
- (let ((sub-menus ()))
- (dolist (dir-and-pattern dirs-and-patterns (make-instance 'menu
- :menu-title name
- :menu-items (nreverse sub-menus)))
- (if (listp dir-and-pattern)
- (push (make-docs-menu-item (first dir-and-pattern) (second dir-and-pattern))
- sub-menus)
- (push *menu-item-separator* sub-menus))) ))
-
-
- ;;; This creates a single directory menu containing as menu items the files
- ;;; in a directory that match a certain pattern. When the menu item is
- ;;; selected, the file is open for editing.
- ;;;
- (defun make-docs-menu-item (dir pattern)
- (let ((l ())
- (file-pattern (concatenate 'simple-string dir pattern)))
- (dolist (file
- (directory file-pattern :test #'(lambda (x) (equal (mac-file-type x) :text)))
- (make-instance 'menu :menu-title dir :menu-items (nreverse l)))
- (push (make-instance 'menu-item
- :menu-item-title (file-namestring file)
- :menu-item-action (eval `(function (lambda () (ed ,file)))))
- l)) ))
-
-
- (provide :docs-menu)
-